home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_dos.lha / dos / sphdoc / sphigs.doc
Encoding:
Text File  |  1991-11-26  |  29.7 KB  |  742 lines

  1.                     SPHIGS for ANSI-C ~~~~ (v0.8, 25 Nov 90)
  2.                              David Frederick Sklar
  3.  
  4. The Simple Programmer's Hierarchical Graphics Standard is composed of a library
  5. of functions, and a header file ("sphigs.h") that defines custom data types 
  6. and constants, and which prototypes all SPHIGS routines. This paper is a 
  7. complete but extremely terse description of the ANSI-C binding. You must read 
  8. Chapter 7 of Computer Graphics --- Principles and Practice (Foley, van Dam, 
  9. Feiner, and Hughes, Addison-Wesley, 1990) for a full description of SPHIGS. 
  10. NOTE: SPHIGS requires the SRGP library. 
  11.  
  12.  
  13.  
  14. 0)    Comparison with Textbook Specification 
  15.  
  16.  
  17.  
  18. 1)    States of the System 
  19.  
  20.        1)   initializing the system 
  21.  
  22.        2)   controlling screen regeneration 
  23.  
  24.  
  25.  
  26. 2)    Maintenance of the Structure Database 
  27.  
  28.        1)   macroscopic editing 
  29.  
  30.        2)   intra-structure editing 
  31.  
  32.  
  33.  
  34. 3)    Coordinate Systems 
  35.  
  36.        1)   geometric data types 
  37.  
  38.        2)   viewing transformations 
  39.  
  40.        3)   modeling transformations 
  41.  
  42.  
  43.  
  44. 4)    Color and Shading 
  45.  
  46.  
  47.  
  48. 5)    Creation of Graphics Objects 
  49.  
  50.        1)   polyLine 
  51.  
  52.        2)   polyMarker 
  53.  
  54.        3)   text 
  55.  
  56.        4)   fill area 
  57.  
  58.        5)   polyhedron 
  59.  
  60.        6)   rendering modes 
  61.  
  62.        7)   execution of subordinate structures 
  63.  
  64.  
  65.  
  66. 6)    Dynamic Invisibility and Highlighting 
  67.  
  68.  
  69.  
  70. 7)    Input 
  71.  
  72.        1)   control of input devices 
  73.  
  74.        2)   pick correlation 
  75.  
  76.  
  77.  
  78. 8)    Control of Table Sizes 
  79.  
  80.  
  81.  
  82. *************** SECTION 0 >>>> Comparison with Textbook Description
  83.  
  84. This section describes how SPHIGS differs from its textbook description, lists 
  85. features that are not currently supported but will be supported in future 
  86. releases, and lists currently known bugs. 
  87.  
  88. Viewports: In the textbook figures, viewport boundaries were depicted via 
  89. dashed rectangular outlines. This has been deemed too obtrusive for practical 
  90. use and has been replaced by a background color --- thus, SPHIGS viewports are 
  91. opaque (a violation of the PHIGS standard). The application can specify a 
  92. different background color for each view. The default color is white, meaning 
  93. the viewport boundary will not be obvious. It is suggested that extremely light
  94. pastel-ish colors be used. (NOTE: unfortunately, there is currently no method 
  95. for depicting viewport boundaries on black-and-white systems.) Overlapping 
  96. viewports should be avoided. 
  97.  
  98. Rendering and Color: The FLAT and GOURAUD rendering modes are not currently 
  99. supported; LIT_FLAT is the current "quality" rendering mode. The textbook did
  100. not describe how colors are assigned to objects for the purposes of shaded 
  101. rendering in the LIT_FLAT rendering mode, nor did it describe how simulated 
  102. shading is achieved on monochrome implementations. See section 4. 
  103.  
  104. SPHIGS in a windowing environment: When run on X11 or the Macintosh, the SPHIGS
  105. "screen" appears in a window whose size is determined by the application at 
  106. initialization time and may be changed by the user via a window manager action.
  107.  
  108. Matrices for viewing/modeling: If you choose to examine the actual matrices 
  109. created and manipulated by SPHIGS, don't expect them to correlate with the 
  110. matrices you would obtain by following the instructions in Chapters 5 and 6. 
  111. They will in fact be the transpose matrices of the ones you would expect. 
  112. (SPHIGS' internal linear algebra package uses row vectors instead of column 
  113. vectors.) As a result, when you request preconcatenation, SPHIGS internally 
  114. postconcatenates, and vice versa. 
  115.  
  116. Viewing BUG! When you call SPH_evaluateViewMappingMatrix with a projection type
  117. of ORTHOGRAPHIC, it is possible that the front and back clipping-planes 
  118. distances you specify in that call will be lost. The problem has a simple 
  119. avoidance mechanism: if you always call SPH_setViewRepresentation immediately 
  120. after evaluating the view matrices, the problem never occurs. 
  121.  
  122. Subroutine specifications (calling sequence, return value, existence): Textbook
  123. specifications are no longer valid for SPH_set\-Rendering\-Mode and for all 
  124. matrix-calculation commands (SPH_scale, etc.) Also, the subroutine SPH_
  125. copyStructure does not yet exist. 
  126.  
  127. Input: Pick correlation is currently supported only for polyhedra and fill area
  128. primitives. 
  129.  
  130. Name sets for highlighting and invisibility: Not supported in this version! 
  131.  
  132. Fill areas: They are supported but have not been tested well. It appears they 
  133. may not be sorted correctly with polyhedra in LIT_FLAT mode. Moreover, they 
  134. (like polyhedron facets) have a visible "outside" and an invisible 
  135. "inside"; thus, they disappear completely when viewed from one side, which is
  136. quite unintuitive. 
  137.  
  138. Fill areas and polyhedron faces: MUST BE CONVEX! No exceptions! 
  139.  
  140. Modeling: Although certainly a single scene should be able to "contain" both 
  141. solid objects (e.g., polyhedra) and non-solid objects (e.g., lines, text), the 
  142. current version of SPHIGS' LIT_FLAT rendering mode does not handle this well. 
  143. All non-solid objects are drawn first, and then the fill areas and polyhedra 
  144. facets are drawn back to front. A line may thus be covered by a facet even 
  145. though it is in front. It is thus strongly recommended that you do not mix 
  146. polyhedra and any other types of objects together in a single scene if you wish
  147. to view it using LIT_FLAT rendering mode. 
  148.  
  149. Shaded rendering: In this mode (LIT_FLAT), SPHIGS must perform a "z-sort" to 
  150. determine the order in which the faces should be drawn. The z-sort algorithm in
  151. this version of SPHIGS is relatively stable, but there are bugs that occur, 
  152. usually when an edge of one face is coplanar with another face. Moreover, this 
  153. version of SPHIGS does NOT handle faces that intersect and faces that are 
  154. non-convex. 
  155.  
  156.  
  157.  
  158. *************** SECTION 1 >>>> States of the System
  159.  
  160. SPHIGS must be enabled before use, and disabled after use. At any time, SPHIGS 
  161. is in exactly one of the following three operating states: 
  162.  
  163. **  SPHIGS disabled (initial state) 
  164.  
  165. **  SPHIGS enabled, no structure open 
  166.  
  167. **  SPHIGS enabled, structure open 
  168.  
  169.  
  170.  
  171. *************** SECTION 1.1 >>>> initializing the system
  172.  
  173.  
  174. void SPH_begin (int width, int height, int planecount, int shadecount);
  175.  
  176.     This routine initializes SPHIGS and SRGP, and places SPHIGS in the 
  177.     enabled/no-structure-open state. The virtual-screen window is opened, with 
  178.     its initial dimensions (measure in pixels) determined by the first two 
  179.     parameters. (It can be resized by the user with a window manager, if the 
  180.     underlying SRGP platform supports that functionality.) The NPC "unit 
  181.     extent" (0.0 to 1.0 on both x and y) will map to the largest square that 
  182.     fits in this area. 
  183.  
  184. The last two parameters allow the application to request color resources. This 
  185. is explained in section 4. 
  186. ------------------------------------------------------------------------------
  187. void SPH_end (void)
  188.  
  189.     The virtual screen window is closed, and SPHIGS enters the disabled state. 
  190.  
  191.  
  192.  
  193. *************** SECTION 1.2 >>>> controlling screen regeneration
  194.  
  195. Whenever the application changes the structure database, SPHIGS regenerates the
  196. screen image immediately unless the implicit-regeneration mode has been set to 
  197. SUPPRESSED. Its default value is ALLOWED. When implicit regeneration is 
  198. suppressed, regeneration can be explicitly forced via the second function 
  199. below. Otherwise, regeneration occurs when the implicit regeneration mode is 
  200. restored to ALLOWED. 
  201.  
  202. typedef enum {SUPPRESSED, ALLOWED} regenMode;
  203. void SPH_setImplicitRegenerationMode (regenMode)
  204. void SPH_regenerateScreen (void)
  205.  
  206.  
  207.  
  208. *************** SECTION 2 >>>> Maintenance of the Structure Database
  209.  
  210. The structure database is composed of two parts: 
  211.  
  212. **  Conceptually, a fixed number of structures exist in the universe, all 
  213.     initially empty. They are indexed by the numbers 0 through MAX_STRUCTURE_
  214.     ID. Because a structure may invoke other structures, this set of structures
  215.     actually is a set of interlocking DAGs (directed acyclic graphs) that we 
  216.     call networks. 
  217.  
  218. **  A view table having a fixed number of views exists; the views are indexed 
  219.     by the numbers 0 through MAX_VIEW_INDEX. Each view includes 0 or more 
  220.     references to networks; a single network can be referenced by more than one
  221.     view. Not all networks are referenced. Those that are referenced are said 
  222.     to be posted and are therefore potentially visible. 
  223.  
  224. There are two genres of editing: 
  225.  
  226. **  macro-structure editing of the structure database: posting/unposting 
  227.     structures, deleting structures and networks, etc. 
  228.  
  229. **  intra-structure editing: modification of the contents of a single structure
  230.     
  231.  
  232.  
  233.  
  234. *************** SECTION 2.1 >>>> macro-structure editing
  235.  
  236. The following functions post and unpost. They may be called only when there is 
  237. no open structure. The screen is regenerated immediately unless automatic 
  238. regeneration is disabled. 
  239.  
  240. typedef int structure_ID, view_ID;
  241. void SPH_postRoot (structure_ID, view_ID);
  242. void SPH_unpostRoot (structure_ID, view_ID);
  243. void SPH_unpostAllRoots (view_ID);
  244.  
  245.  
  246.  
  247. *************** SECTION 2.2 >>>> intra-structure editing
  248.  
  249. One must open a structure in order to edit it. Only one structure may be opened
  250. at any time. All structures exist from time zero; one never creates a 
  251. structure, one merely opens an empty structure and edits it. The editing 
  252. operations are not considered "official" until the structure is closed, so 
  253. screen updating is not performed while the structure is open. 
  254.  
  255. void SPH_openStructure (structure_ID);
  256. void SPH_closeStructure (void);
  257.  
  258. When a structure is opened, the element pointer is set to point to the very 
  259. last element in the structure. Since elements are indexed by ascending 
  260. integers, starting with 1, this means the element pointer is initialized to N 
  261. (where N is the number of elements in the structure). If the structure being 
  262. opened is empty, the element pointer is initialized to 0. The element pointer 
  263. may be moved via the following functions. Movement to index 0 is useful for 
  264. inserting new elements at the very beginning of a non-empty structure. Movement
  265. to an index which is meaningless (less than 0 or greater than N) causes a fatal
  266. error. Movement to a label causes a forward scan through the structure starting
  267. from (but not including) the current position of the element pointer; thus it 
  268. is typically wise to set the element pointer to 0 before attempting to move the
  269. element pointer to a label. If the label is not found, a fatal error occurs. 
  270.  
  271. typedef int elementIndex, label_ID;
  272. void SPH_setElementPointer (elementIndex);
  273. void SPH_offsetElementPointer (int delta);
  274. void SPH_moveElementPointerToLabel (label_ID);
  275.  
  276. When a structure is open for editing, the application may inquire the index of 
  277. the current element: 
  278.  
  279. elementIndex SPH_inquireElementPointer (void);
  280.  
  281. The most common form of editing is simply the insertion of new elements into a 
  282. structure. Whenever an element-generator function is called, the new element is
  283. placed immediately after the current element, and the element pointer is 
  284. advanced to point to the new element. 
  285.  
  286. Label elements have integer names which must be unique within the structure 
  287. owning it. The following function generates a label element. 
  288.  
  289. void SPH_label (label_ID);   <!>
  290.  
  291.     NOTE:   Throughout this document, each presentation of an element-generator
  292.             routine is "highlighted" by the presence of this symbol: <!> 
  293.  
  294. The following functions delete elements and automatically renumber the 
  295. survivors. In all cases, after the deletion is made, the element pointer is 
  296. moved to point to the element immediately preceding the first element deleted. 
  297. The first function deletes the element indexed by the current value of the 
  298. element pointer. The second function deletes the elements lying between, and 
  299. including, the elements specified by the two element identifiers. The first 
  300. identifier must be less than the second one; a fatal error occurs otherwise. 
  301. The third function deletes the elements lying between, but not including, the 
  302. label elements specified. The first label must appear in the structure before 
  303. the second one, and both must appear after the current value of the element 
  304. pointer; a fatal error occurs otherwise. 
  305.  
  306. void SPH_deleteElement (void);
  307. void SPH_deleteElementsInRange (elementIndex first, elementIndex second);
  308. void SPH_deleteElementsBetweenLabels (label_ID first, label_ID second);
  309.  
  310.  
  311.  
  312. *************** SECTION 3 >>>> Coordinate systems
  313.  
  314.  
  315.  
  316.  
  317. *************** SECTION 3.1 >>>> geometric data types
  318.  
  319. The following data types are defined in order to simplify the storage and 
  320. specification of vectors, points, and matrices: 
  321.  
  322. typedef double point[3], vector[3];
  323. typedef double matrix[4][4];
  324.  
  325. Vectors or points may be initialized using this function: 
  326.  
  327. double *SPH_defPoint (pt,  x, y, z)
  328. double *pt;    /* pointer to first of three consecutive doubles */
  329. double x, y, z;
  330.  
  331.  
  332.  
  333. *************** SECTION 3.2 >>>> viewing transformations
  334.  
  335. The SPHIGS viewing system involves an intermediate coordinate system called the
  336. VRC (Viewing Reference Coordinates). This first transformation simply reorients
  337. the world by specifying a new set of axes: UVN. The matrix which performs this 
  338. is called the view-orientation matrix and can be calculated using the following
  339. function. The final argument to the function must be a pointer to a matrix (to 
  340. be initialized by the function) allocated by the application. 
  341.  
  342. void
  343. SPH_evaluateViewOrientationMatrix
  344.    (point view_ref_point, vector view_plane_normal, vector view_up_vector,
  345.     matrix vo_matrix);
  346.  
  347. The next transformation sets up the view volume, which maps VRC to NPC 
  348. (Normalized Projection Coordinates). To be more specific, it maps the contents 
  349. of the view volume to a paralleliped in NPC space. (It is recommended, but not 
  350. enforced, that the rectangle lie wholly inside the NPC bounded space [0,0]--->
  351. [1,1].) The matrix which performs this is called the view-mapping matrix. 
  352.  
  353. void 
  354. SPH_evaluateViewMappingMatrix
  355.    (double umin, double umax, 
  356.     double vmin, double vmax,   /* boundaries of window on view plane */
  357.     int proj_type,        /* either PERSPECTIVE or ORTHOGRAPHIC */
  358.     point proj_ref_point,   /* in uvn coordinates */
  359.     double proj_front_clip_distance,
  360.        double proj_back_clip_distance,  /* offsets from VRP on n axis  */
  361.     /* 3D viewport: in this version, minz and maxz are ignored */
  362.     double proj_NPCviewport_minx, double proj_NPCviewport_maxx,
  363.     double proj_NPCviewport_miny, double proj_NPCviewport_maxy,
  364.     double proj_NPCviewport_minz, double proj_NPCviewport_maxz,
  365.     matrix vm_matrix);
  366.  
  367. It is very important to understand that the projection-reference point and the 
  368. window's boundaries (umin, umax, vmin, vmax) are specified NOT in WC, but as 
  369. offsets from the VRP that is set by the orientation matrix. This means that in 
  370. order to perform an animation which involves only simple camera motion, with no
  371. change in the "focal length" and no strange warpings, all one needs to do is 
  372. change the view-orientation matrix. The prp will "follow" the vrp as the view
  373. orientation is changed. 
  374.  
  375. Notice that there is no explicit way to specify focal length in this system. 
  376. The distance between the VRP and the PRP can be manipulated to achieve similar 
  377. results. Be careful! The z coordinate of the PRP must be positive! Also, if you
  378. specify the PRP in such a way that a line between it and the center of the view
  379. plane is not perpindicular to the view plane, shearing will occur. 
  380.  
  381. The setting of an entry in the view table requires specification of both the 
  382. matrices as well as a re-specification of the NPC viewport (again, with minz 
  383. and maxz ignored): 
  384.  
  385. void
  386. SPH_setViewRepresentation
  387.    (int view_index, 
  388.     matrix vo_matrix, matrix vm_matrix,
  389.     double clip_NPCviewport_minx, double clip_NPCviewport_maxx, 
  390.     double clip_NPCviewport_miny, double clip_NPCviewport_maxy,
  391.     double clip_NPCviewport_minz, double clip_NPCviewport_maxz);
  392.  
  393. The background color for a view's rectangular region of the screen is white by 
  394. default, but you may change it (on a per-view basis): 
  395.  
  396. void SPH_setViewBackgroundColor (int viewindex, int color);
  397.  
  398.  
  399.  
  400. *************** SECTION 3.3 >>>> modeling transformations
  401.  
  402. Each structure has its own modeling coordinate system (MCS); primitives 
  403. specified within it are placed in its MCS. When the execution of a structure 
  404. (during traversal) begins, its local modeling transformation is initialized to 
  405. the "identity" transformation. When a primitive element is executed, its raw 
  406. coordinates are transformed by the current value of the local modeling 
  407. transformation in order to place it within the MCS. When a structure-execution 
  408. element is executed, the MCS of the subordinate structure is mapped into the 
  409. local MCS using the local modeling transformation: thus the image of the 
  410. subordinate network is transformed as a single entity to be placed within the 
  411. local MCS. 
  412.  
  413. The following function generates a structure element which, when executed, 
  414. affects the local modeling transformation matrix, either by replacing 
  415. (assigning) it or by concatenating it with a given matrix. 
  416.  
  417. typedef enum {ASSIGN, PRECONCATENATE, POSTCONCATENATE} updateType;
  418. void SPH_setModelingTransformation (matrix mat, updateType);  <!>
  419.  
  420. An application can use the following functions for creating a matrix to be 
  421. stored or to be used to set a modeling transformation. Rotation, translation, 
  422. scaling, and compositions thereof are supported. Rotation angles are specified 
  423. in degrees, positive angles representing counter-clockwise rotation. In all 
  424. functions, the last parameter specifies the application-allocated area (large 
  425. enough to store a 4-by-4 array of doubles) in which the function is to place 
  426. the calculated matrix. 
  427.  
  428. void SPH_scale (double scaleX, double scaleY, double scaleZ,  matrix result) 
  429. void SPH_rotateX (double angleDegrees,  matrix result)
  430. void SPH_rotateY (double angleDegrees,  matrix result)
  431. void SPH_rotateZ (double angleDegrees,  matrix result)
  432. void SPH_translate 
  433.      (double deltaX, double deltaY, double deltaZ,  matrix result)
  434.  
  435. void SPH_composeMatrix (matrix mat1, matrix mat2,  matrix result)
  436.  
  437. In the textbook's Pascal code, a matrix could be calculated and made into an 
  438. element in one statement, because Pascal can return arrays: 
  439.  
  440.    SPH_setModelingTransformation (SPH_scale(5.0,3.0,1.0), ASSIGN);
  441.  
  442. It was not possible to design an elegant method in ANSI C for the calculation 
  443. routines to return a matrix in a manner that would allow the same convenience. 
  444. Thus, creating a transformation element requires two C statements (unless the 
  445. matrix is already available): 
  446.  
  447.    SPH_scale (5.0, 3.0, 1.0,  mat);
  448.    SPH_setModelingTransformation (mat, ASSIGN);
  449.  
  450. The SPHIGS header file sphigs.h defines a macro called SPH_setModXform that can
  451. come to the rescue if you abhor the two-statement sequence. The macro assumes 
  452. that you have declared and are using a matrix called temp_matrix. Here I show 
  453. the usage of the macro for the creation of a scale element: 
  454.  
  455.    SPH_setModXform (SPH_scale(5.0, 3.0, 1.0, temp_matrix), ASSIGN);
  456.  
  457.  
  458.  
  459. *************** SECTION 4 >>>> Color and Shading
  460.  
  461. SPHIGS provides a device-independent method for dealing with color. An 
  462. application can load the SPHIGS color table without concern for the number of 
  463. colors actually available, and can assign colors to objects equally carefree. 
  464. SPHIGS maps unavailable entries to white (for interiors) or black (for lines, 
  465. text, markers, etc.). Moreover, when LIT_FLAT rendering is used, SPHIGS 
  466. simulates shading (by using bitmap patterns) when it is not possible to use 
  467. true colors for the shading. 
  468.  
  469. The total number of available colors is dependent upon the number of planes 
  470. requested via the third parameter to SPH_begin, and on the capabilities of the 
  471. underlying hardware. See the SRGP reference manual for information on color 
  472. planes. 
  473.  
  474. SPHIGS divides up the available colors in this manner: The first two colors are
  475. fixed at white (0) and black (1); the application may not modify these entries.
  476. The next C entries (2 through (C+2)) are called custom colors and are 
  477. application-settable. The first F custom colors are called flexicolors. When a 
  478. flexicolor is assigned to the interior of a facet or fill area, SPHIGS displays
  479. an appropriately darkened shade of that color when LIT_FLAT rendering mode is 
  480. used. When a non-flexicolor is assigned to a facet or fill area, SPHIGS must 
  481. simulate shading by using bitmap patterns. 
  482.  
  483. The values of F and C are calculated by SPHIGS based on the total number of 
  484. available SRGP colors and on the value of the 4'th parameter of SPH_begin: the 
  485. number of shades you wish to be created for each flexicolor. Obviously: the 
  486. larger the number of shades per flexicolor, the fewer flexicolors SPHIGS will 
  487. be able to provide. 
  488.  
  489. After SPH_begin returns, you can inquire the values of F and C by examining 
  490. these global variables: NUM_OF_FLEXICOLORS and NUM_OF_APPL_SETTABLE_COLORS. 
  491.  
  492. Currently, SPHIGS only provides one routine for loading the color table: 
  493. ------------------------------------------------------------------------------
  494. void SPH_loadCommonColor (int colorindex, char *colorname);
  495.  
  496.     For information on the second parameter, see the SRGP reference manual. 
  497.     When you load a color into a flexicolor entry, SPHIGS automatically 
  498.     generates a range of shades for that color. For this reason, you must not 
  499.     bypass this routine by calling SRGP directly. 
  500.  
  501. SPHIGS renders a lit-flat view using a simple lighting model using a single 
  502. point light source (specified in UVN coordinates, and thus attached to the 
  503. camera and mobile as the camera is mobile) and Lambertian reflection. Ambient 
  504. light is automatically extant as well. No light-source attenuation is 
  505. considered to exist, and surfaces are not self-occluding. Because of these 
  506. restrictions, best results occur when the light source is kept well away from 
  507. the scene's objects themselves. The default position of the light source is 
  508. above and behind the camera at a distance approximating infinity; it thus acts 
  509. as a "sun" simulator. 
  510.  
  511.  
  512.  
  513. *************** SECTION 5 >>>> Creation of Graphics Objects
  514.  
  515.  
  516.  
  517.  
  518. *************** SECTION 5.1 >>>> polyLine
  519.  
  520.  
  521. SPH_polyLine (int vertex_count, point *vertices) <!>
  522.  
  523. Attributes affecting the polyLine primitive: 
  524.  
  525. SPH_setLineStyle (int value)  <!>  /* See SRGP manual. */
  526. SPH_setLineColor (int value)  <!>
  527. SPH_setLineWidthScaleFactor (double scale_factor)  <!>
  528.  
  529.  
  530.  
  531. *************** SECTION 5.2 >>>> polyMarker
  532.  
  533.  
  534. SPH_polyMarker (int vertex_count, point *vertices) <!>
  535.  
  536. Attributes affecting the polyMarker primitive: 
  537.  
  538. SPH_setMarkerStyle (int value)  <!>  /* See SRGP manual. */
  539. SPH_setMarkerColor (int value)  <!>
  540. SPH_setMarkerSizeScaleFactor (double scale_factor)  <!>
  541.  
  542.  
  543.  
  544. *************** SECTION 5.3 >>>> text
  545.  
  546. Only the origin is affected by modeling and viewing transformations; the text 
  547. itself is always horizontal, aligned with the virtual screen window. 
  548.  
  549. SPH_text (point origin, char *str) <!>
  550.  
  551. The attributes affecting text are like their SRGP counterparts. In fact, you 
  552. must call SRGP_loadFontTable to load fonts. 
  553.  
  554. SPH_setTextFont (int font_index)  <!> 
  555. SPH_setTextColor (int color_index) <!>
  556.  
  557. NOTE: In this version of SPHIGS, text and lines are not sorted spatially with 
  558. solid objects, so it is possible for a text or line object to be obscured by a 
  559. polyhedron or fill area that is actually behind it, when rendered in LIT_FLAT 
  560. mode. 
  561.  
  562.  
  563.  
  564. *************** SECTION 5.4 >>>> fill area
  565.  
  566. A fill area must be convex and planar; SPHIGS does not attempt to verify either
  567. of these conditions. Like polyhedra facets (described next), the order in which
  568. you specify the vertices determines which side is "outside". Only the outside
  569. side is visible in non-wireframe modes. Warning: in this version of SPHIGS, 
  570. fill areas are known to be buggy in LIT_FLAT mode. 
  571.  
  572. SPH_fillArea (int vertex_count, point *vertices) <!>
  573.  
  574. Attributes that affect the appearance of both fill-area and polyhedron objects:
  575.  
  576. SPH_setInteriorColor (int color_index) <!>
  577. SPH_setEdgeColor (int color_index) <!>
  578. SPH_setEdgeStyle (int value) <!>  /* same values as for line style */
  579. SPH_setEdgeFlag (int value) <!>  /* EDGE_VISIBLE or EDGE_INVISIBLE */
  580. SPH_setEdgeWidthScaleFactor (double scale_factor) <!>
  581.  
  582. See section 4 for a description of the color-index attribute. 
  583.  
  584.  
  585.  
  586. *************** SECTION 5.5 >>>> polyhedron
  587.  
  588. To create a polyhedron element, you present a complete list of the vertices, 
  589. implicitly indexed from 0 to (vcount-1). You describe the facets by presenting 
  590. a single array of numbers (SPHIGS data type vertex_index that actually stores a
  591. concatenated set of facet descriptions. Each facet description is a sequence of
  592. (V+1) numbers, where V is the number of vertices in the facet. The first V 
  593. numbers are indices into the vertex list; the last number is (-1) and acts as a
  594. sentinel ending the facet specification. The vertex indices for a facet must be
  595. presented in counterclockwise order (as seen when looking at the facet's 
  596. "outside" face). Because each facet must be a closed polygon, the first 
  597. vertex in the list is implicitly the last as well. 
  598.  
  599. The data type vertex_index must be used by the application programmer in order 
  600. to guarantee future compatibility. It is of course typedef'ed to either a short
  601. or an int in the sphigs.h file. 
  602.  
  603. Note: In this beta version of SPHIGS, FACETS MUST BE CONVEX! 
  604.  
  605. void SPH_polyhedron   <!>
  606.    (int vertex_count, int facet_count,
  607.     point *vertices,  vertex_index *facets);
  608.  
  609. The appearance of a polyhedron is affected by the same attributes that affect 
  610. the fill-area primitive. 
  611.  
  612.  
  613.  
  614. *************** SECTION 5.6 >>>> rendering modes
  615.  
  616. SPHIGS currently supports only two of the rendering modes described in the 
  617. textbook. The rendering mode is set by the following function: 
  618.  
  619. SPH_setRenderingMode (int value)  /* WIREFRAME_RAW, WIREFRAME (default), LIT_FLAT */
  620.  
  621. The raw wireframe mode renders without performing hidden-surface elimination or
  622. clipping. Because of this, strange results (and lots of warning messages) occur
  623. if objects lie behind the camera. The default mode (WIREFRAME) performs 
  624. clipping and hidden-surface elimination, but only draws edges. The most 
  625. expensive mode draws surfaces as filled polygons whose colors are determined by
  626. lighting/shading algorithms. (See section 4 of this reference manual for a 
  627. complete description.) In this version of SPHIGS, it is recommended that only 
  628. fill areas and polyhedra be posted to views being rendered in LIT_FLAT mode. 
  629. See section 0 for a more detailed warning. 
  630.  
  631.  
  632.  
  633. *************** SECTION 5.7 >>>> execution of subordinate structures
  634.  
  635. This function inserts a structure-execution element into the currently open 
  636. structure. The structure referenced by the argument need not already be 
  637. defined, as explained previously, for all unknown structures are implied empty 
  638. structures. 
  639.  
  640. void SPH_executeStructure (int structureIndex) <!>
  641.  
  642.  
  643.  
  644. *************** SECTION 6 >>>> Dynamic Invisibility and Highlighting
  645.  
  646. NOT AVAILABLE IN THIS VERSION!!  
  647.  
  648.  
  649.  
  650. *************** SECTION 7 >>>> Input
  651.  
  652.  
  653.  
  654.  
  655. *************** SECTION 7.1 >>>> control of input devices
  656.  
  657. The locator measure is similar to that of the SRGP locator, but the position is
  658. a 3D NPC coordinate (with z=0), and the index of the non-empty view (i.e., 
  659. having at least one posted root) with the highest priority (i.e. index) that 
  660. encloses the position is also returned: 
  661.  
  662. typedef struct {
  663.     point position;
  664.     int   view_index;
  665.     int   button_chord[3];
  666.     int   button_of_last_transition;
  667. } locator_measure;
  668.  
  669. Control of the input devices is performed a la SRGP. Any positions are 3D NPC 
  670. points (z ignored) instead of 2D PDC points. 
  671.  
  672. #define SPH_setInputMode SRGP_setInputMode
  673. #define SPH_waitEvent SRGP_waitEvent
  674. #define SPH_getKeyboard SRGP_getKeyboard
  675. #define SPH_sampleKeyboard SRGP_sampleKeyboard
  676. #define SPH_setKeyboardProcessingMode SRGP_setKeyboardProcessingMode
  677. #define SPH_setKeyboardEchoColor SRGP_setKeyboardEchoColor
  678. #define SPH_setKeyboardEchoFont SRGP_setKeyboardEchoFont
  679. #define SPH_setKeyboardMeasure SRGP_setKeyboardMeasure
  680. #define SPH_setLocatorEchoCursorShape SRGP_setLocatorEchoCursorShape
  681. #define SPH_setLocatorButtonMask SRGP_setLocatorButtonMask
  682.  
  683. void SPH_getLocator (locator_measure*);
  684. void SPH_sampleLocator (locator_measure*);
  685. void SPH_setLocatorMeasure (point position);
  686. void SPH_setKeyboardEchoOrigin (point position);
  687.  
  688.  
  689.  
  690. *************** SECTION 7.2 >>>> pick correlation
  691.  
  692. The NPC point returned from the locator can be sent to the pick-correlation 
  693. utility: 
  694.  
  695. void SPH_pickCorrelate (point npc_position, int view_index, 
  696.             pickInformation *pickinfo);
  697.  
  698. The information is returned in a variable of type pickInformation: 
  699.  
  700. typedef
  701.    struct {
  702.      int structureID;
  703.      int elementIndex;
  704.      int elementType;   /* symbolic constants in elementType.h */
  705.    } pickPathItem;
  706. typedef pickPathItem pickPath[MAX_HIERARCHY_LEVEL];
  707. typedef struct {
  708.      int pickLevel;
  709.      pickPath path;
  710.    } pickInformation;
  711.  
  712. When no primitive is close enough to the cursor position, the value of the 
  713. pickLevel field is returned as 0. When pickLevel is greater than zero, it 
  714. specifies the length of the path from the root to the picked primitive. In this
  715. latter case, elements [0] through [pickLevel-1] of the path array return the 
  716. identification of the structure elements involved in the path. Of course, 
  717. elements [0] through [pickLevel-2] will always be structure-execution elements,
  718. whereas the [pickLevel-1] element will always be an output primitive. For each 
  719. element, the information presented is: its ID, its index within its parent 
  720. structure, a code presenting the element's type (e.g., ELTYP__EXECUTE_
  721. STRUCTURE, ELTYP__POLYHEDRON), and the pick ID of the element. 
  722.  
  723. The pick ID is an attribute that is local to a structure (not inherited), 
  724. begins with the value 0, and changed by elements created via: 
  725.  
  726. SPH_setPickIdentifier (int pick_ID);  <!>
  727.  
  728.  
  729.  
  730. *************** SECTION 8 >>>> Control of Table Sizes
  731.  
  732. The tables that store views and structures have default sizes that in many 
  733. cases are acceptable. You may, however, choose to reduce the size of a table to
  734. save memory (if you're working on a Mac Plus, for instance) or increase the 
  735. size of a table if you need more entries. You must change the size of a table 
  736. before you initialize SPHIGS! 
  737.  
  738. void SPH_setMaxStructureID (int);
  739. void SPH_setMaxViewIndex (int);
  740.  
  741.     See sphigs.h for the defaults for these sizes. 
  742.